<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('配置通讯费')" />
    <th:block th:include="include :: datetimepicker-css" />
    </head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="changeFeeRecord_add">
                <p>补录通讯费，对已使用的机器进行通讯费设置</p>
            <div class="form-group">
                <label class="col-sm-3 control-label  is-required">代理商编号：</label>
                <div class="col-sm-8">
                    <input name="agentNum" onclick="selectAgent()" readonly id="agentNum" type="text" class="form-control" required>
                    <i class="fa fa-search" style="margin-top: -22px;margin-right:3px;float:right;"></i>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">代理商名称：</label>
                <div class="col-sm-8">
                    <input name="agentName" class="form-control" id="agentName" type="text" readonly required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">截止时间：</label>
                <div class="col-sm-8">
                    <input name="start" id="start" class="form-control time-input" style="width: 221px; display: inline-block" type="text" placeholder="开始时间" readonly required>
                    ——
                    <input name="end" id="end" class="form-control time-input" style="width: 222px; display: inline-block" type="text" placeholder="结束时间" readonly required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">终端类型：</label>
                <div class="col-sm-8">
                    <select name="posType" id="posType" class="form-control m-b">
                        <option value="4">电签</option>
                        <option value="0">传统</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">终端数量：</label>
                <div class="col-sm-8">
                    <input name="machineCount" id="machineCount"  onclick="getSnCount()" class="form-control" readonly type="text" placeholder="点击获取终端数量">
                    <i class="fa fa-search" style="margin-top: -22px;margin-right:3px;float:right;"></i>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">流量卡费：</label>
                <div class="col-sm-8">
                    <select name="nowSimFee" class="form-control m-b">
                        <option value="0">0</option>
                        <option value="36">36</option>
                        <option value="48">48</option>
                        <option value="68">68</option>
                    </select>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var prefix = ctx + "terminal/changeFeeRecord"
        $("#form-terminal.changeFeeRecord-add").validate({
            focusCleanup: true
        });

        $("input[name='date']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#changeFeeRecord_add').serialize());
            }
        }

        /**
         * 前往查找带回页面
         */
        function selectAgent() {
            var url =prefix+ "/getAgentInfo";
            $.modal.open("服务商列表" , url, '830',"450");
        }

        /**
         * 查询终端数量
         */
        function getSnCount(){
            if($("#agentNum").val() == null || $("#agentNum").val() == ''){
                $.modal.alertWarning("代理商编号为空！");
                return;
            }else
            if($("#start").val() == null || $("#start").val() == ''){
                $.modal.alertWarning("截至开始时间为空！");
                return;
            }else
            if($("#end").val() == null || $("#end").val() == ''){
                $.modal.alertWarning("截至结束时间为空！");
                return;
            }
            //参数
            var formData = new FormData();
            formData.append("agentNum",$("[name='agentNum']").val());     //代理商编号
            formData.append("start",$("[name='start']").val());           //截至开始时间
            formData.append("end",$("[name='end']").val());               //截至结束时间
            formData.append("posType",$("[name='posType']").val());       //终端类型

            $.ajax({
                url : prefix + "/getSnCount",
                type: 'POST',
                data: formData,
                cache: false,
                contentType: false,
                processData: false,
                success : function(result) {
                    $("#machineCount").val(result.counts);
                }
            });
        }
    </script>
</body>
</html>
